{% extends  'partials/base.html' %}
{% block title %}商品信息{% endblock %}
{% load crispy_forms_tags %}
{% block content %}
{% include 'partials/topside.html' %}
<div class="row my-4">
    <div class="col-md-4">
        {% for message in messages%}
        {% if message %}
        <div class="alert alert-{{message.tags}}">
            {{message}}
        </div>
        {% endif %}
        {% endfor%}
                <div class="card">
            <div class="card-header bg-info text-white">
                添加商品
            </div>
            <div class="card card-body">
        <form method="POST" class="uniForm" action="">
            {% csrf_token %}
            {{form|crispy}}
            <input class="btn btn-info" type="submit" value="添加商品">
        </form>
    </div>
                </div></div>

    <div class="col-md-8">
        <table class="table bg-white">
            <thead class="bg-info text-white">
            <tr>
                <th scope="col">商品名称</th>
                <th scope="col">类型</th>
                <th scope="col">数量</th>
                <th scope="col" >操作</th>
            </tr>
            </thead>
            <tbody>
            {% for item in items%}
            <tr>
                <td>{{item.name}}</td>
                <td>{{item.get_category_display}}</td>
                <td>{{item.quantity}}</td>
                <th scope="row">
                    <a class="btn btn-info btn-sm" href="{% url 'dashboard-product-update' item.id %}">编辑</a>
                    <a class="btn btn-danger btn-sm"
                       href="{% url 'dashboard-product-delete' item.id %}">删除</a></th>
                {% endfor %}
            </tbody>
        </table>
    </div>
</div>
{% endblock %}